package com.atxiaodei.kabudashejimoshi.代理模式.JDK代理;

public class Client {

	public static void main(String[] args) {
		//创建目标对象
		ITraintickets target = new Traintickets();

		//给目标对象，创建代理对象, 可以转成 ITraintickets
		ITraintickets proxyInstance = (ITraintickets)new ProxyFactory().getProxyInstance(target);
//		proxyInstance.tickets();

		// proxyInstance=class com.sun.proxy.$Proxy0 内存中动态生成了代理对象
		System.out.println("proxyInstance=" + proxyInstance.getClass());

		//通过代理对象，调用目标对象的方法
		proxyInstance.tickets();

		proxyInstance.sayHello(" 诸葛孔暗 ");
	}

}